package cn.microvideo.videopf.camera.controller;

import cn.microvideo.videopf.camera.common.RestResult;
import cn.microvideo.videopf.camera.entity.CdnConfirmCameraReq;
import cn.microvideo.videopf.camera.service.CameraService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 摄像机控制器
 *
 * @author 何欢-oreo
 * @version 1.0.0
 * @date 2020/8/20 17:30
 */
@RestController
@RequestMapping
public class CameraController {
    /**
     * 摄像机服务注入
     */
    @Resource
    private CameraService cameraService;

    /**
     * 根据流媒体厂商类型获取所有列表
     *
     * @param smType 流媒体厂商类型
     * @return 流媒体列表
     */
    @GetMapping("/getStreamInfoBySmType/{smType}")
    public RestResult getStreamInfoBySmType(@PathVariable("smType") String smType) {
        return new RestResult<>(cameraService.getStreamInfoBySmType(smType));
    }

    /**
     * 获取G1到G7的摄像机列表
     *
     * @return G1到G7的摄像机列表
     */
    @GetMapping("/getCameraList")
    public RestResult getCameraList() {
        return new RestResult<>(cameraService.getCameraList());
    }
    /**
     * 导出CDN确认的摄像机列表
     *
     * @param cdnConfirmCameraReq 请求参数
     * @param response            响应
     * @return 响应
     * @throws IOException IO异常
     */
    @GetMapping("/export")
    public RestResult exportCdnConfirmCameraList(CdnConfirmCameraReq cdnConfirmCameraReq,
                                                 HttpServletResponse response) throws IOException {
        return cameraService.exportCdnConfirmCameraList(cdnConfirmCameraReq, response);
    }
}
